package com.rd.student.dashuju.wangbo.exercise0728;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class TestPrint {

    public static void main(String[] args) throws Exception{
        FileInputStream fis =
                new FileInputStream("in.txt");
        System.setIn(fis);
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            System.out.println(scanner.next());
        }
        fis.close();
    }

    public static void Out() throws Exception{
        PrintStream ps = new PrintStream(
                new FileOutputStream("out.txt"));
        System.setOut(ps);
        System.out.println("hello out txt");
        ps.close();
    }

    public static void testt() throws Exception{
        FileOutputStream fos =
                new FileOutputStream("streamPrint.txt");
        PrintStream ps = new PrintStream(fos);
        ps.println("hello PrintStream");
        System.out.println("hello PrintStream");
        ps.close();
    }
}
